package com.sinosun.autotestmachine.tools.Collector;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import com.sinosun.autotestmachine.tools.proxy.ErrorCode;

/**
 * 收集器基础类
 * @author HYW
 *
 */
public class BaseCollector {
	private int result;			//存储收集器获取的结果
	private CountDownLatch cd;	//同步机制对象
	
	public BaseCollector() {
		result = ErrorCode.ERR_UNEXPECT_RESULT;
		cd = new CountDownLatch(1);
	}
	
	public int getResult() {
		return this.result;
	}
	
	public void setResult(int result) {
		this.result = result;
	}
	
	public void waitResult() throws InterruptedException {
		cd.await();
	}
	
	public void waitResult(int seconds) throws InterruptedException {
		cd.await(seconds, TimeUnit.SECONDS);
	}
	
	public void countDown() {
		cd.countDown();
	}
}
